import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:imperius_insights/portal/diagnostic/service.dart';
import 'package:imperius_insights/treaty/palette.dart';
import 'package:imperius_insights/treaty/strings.dart';
import 'package:imperius_insights/treaty/styles.dart';

class NetworkErrorWidget extends StatelessWidget {
  final Function refreshBuild;

  const NetworkErrorWidget(this.refreshBuild);

  @override
  Widget build(BuildContext context) {
    return Container(
      child: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              Text(Strings.loading_error_tip,
                  style: styles.content),
              Padding(padding: EdgeInsets.only(bottom: 6)),
              ConstrainedBox(
                constraints: BoxConstraints(minWidth: 160),
                child: RaisedButton(
                  color: palette.theme,
                  highlightColor: palette.theme,
                  colorBrightness: palette.themeBrightness,
                  splashColor: Colors.red,
                  child: Text(Strings.indicator_retry),
                  shape: RoundedRectangleBorder(
                      borderRadius: BorderRadius.circular(20.0)),
                  onPressed: () {
                    refreshBuild();
                  },
                ),
              ),
              ConstrainedBox(
                constraints: BoxConstraints(minWidth: 160),
                child: RaisedButton(
                  color: palette.theme,
                  highlightColor: palette.themeSear,
                  colorBrightness: palette.themeBrightness,
                  splashColor: Colors.red,
                  child: Text(Strings.toolbox_network_title),
                  shape: RoundedRectangleBorder(
                      borderRadius: BorderRadius.circular(20.0)),
                  onPressed: () {
                    Service.navigateToDiagnostic(context);
                  },
                ),
              ),
            ],
          )),
    );
  }
}
